package com.central.common.lb.config;

import cn.hutool.core.util.StrUtil;
import com.central.common.constant.SecurityConstants;
import com.central.common.context.TenantContextHolder;
import feign.RequestInterceptor;

/**
 * @ClassName FeignInterceptorConfig
 * @Description feign拦截器，只包含基础数据
 * @author: puyunqing
 * @Date: 2025/3/21
 */
public class FeignInterceptorConfig {

    public RequestInterceptor baseFeignInterceptor() {
        return template -> {
            // 传递 client
            String tenant = TenantContextHolder.getTenant();
            if (StrUtil.isNotEmpty(tenant)) {
                template.header(SecurityConstants.TENANT_HEADER, tenant);
            }
        };
    }
}
